--抽奖
return function(msg, qq, group)


    local cards = apiXmlGet(tostring(group), "banCard", tostring(qq))
    cards = cards == "" and 0 or tonumber(cards) or 0
    local kcards = apiXmlGet(tostring(group), "keepCard", tostring(qq))
    kcards = kcards == "" and 0 or tonumber(kcards) or 0

    --抽奖
    if msg == "抽奖" then
        -- if cqGetMemberInfo(g,cqGetLoginQQ()).PermitType == 1 or
        --     (cqGetMemberInfo(g,qq).PermitType ~= 1) then
        --     return cqCode_At(qq).."权限不足，抽奖功能无效"
        -- end
        local day = os.date("%Y年%m月%d日")--今天
        local signData = apiXmlGet(tostring(group), "lottery", tostring(qq))

        local data = signData == "" and
        {
            last = 0, --上次抽奖时间戳
            count = 0, --连抽计数
        } or jsonDecode(signData)

        if data.last == day then
            return "你今天已经抽过奖啦"
        end

        if data.last == os.date("%Y年%m月%d日", os.time() - 3600 * 24) then
            data.count = data.count + 1
        else
            data.count = 1
        end
        data.last = day
        local j = jsonEncode(data)
        apiXmlSet(tostring(group), "lottery", tostring(qq), j)



        local kc = math.random(math.modf( data.count / 2 ),data.count)
        kcards = kcards + kc --连抽奖励
        apiXmlSet(tostring(group), "keepCard", tostring(qq), tostring(kcards))

        -- apiHttpImageDownload("http://q.qlogo.cn/headimg_dl?dst_uin="..qq.."&spec=100","head",tostring(qq))
        
        if math.random() > 0.9 then
            local banTime = math.random(1, 10)
            cqSetGroupBanSpeak(group, qq, banTime * 60)
            apiImageandtext("head\\"..tostring(qq),"恭喜中奖：\r\n  禁言"..tostring(banTime).."分钟\r\n\r\n连抽奖励:\r\n  "..tostring(kc).."张免禁卡")
            return "[CQ:image,file=head\\"..tostring(qq)..".jpg]"

        elseif math.random() > 0.5 then
            local keepCard = math.random(1, 3)
                kcards = kcards + keepCard
                apiXmlSet(tostring(group), "keepCard", tostring(qq), tostring(kcards))
                apiImageandtext("head\\"..tostring(qq),"恭喜中奖：\r\n  "..tostring(keepCard).."张免禁卡\r\n\r\n连抽奖励:\r\n  "..tostring(kc).."张免禁卡")
                return "[CQ:image,file=head\\"..tostring(qq)..".jpg]"
        else
            local banCard = math.random(1, 6)
            cards = cards + banCard
            apiXmlSet(tostring(group), "banCard", tostring(qq), tostring(cards))
            apiImageandtext("head\\"..tostring(qq),"恭喜中奖：\r\n  "..tostring(banCard).."张禁言卡\r\n\r\n连抽奖励:\r\n  "..tostring(kc).."张免禁卡")
            return "[CQ:image,file=head\\"..tostring(qq)..".jpg]"
        end
    end
end
